<template>
  <div class="health-data pad">
    <div class="head">
      <span>数据维护</span>
    </div>
    <el-tabs class="m-t-b" type="border-card" @tab-click="tabClick">
      <el-tab-pane label="标签维护">
        <div class="header-con">
          <el-button @click="openLabelDialog" style="margin-right: 10px;" type="primary"><i class="el-icon-plus"></i> 添加标签</el-button>
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :disabled="isUploading"
            :http-request="uploadExcel"
            :before-upload="beforeAvatarUpload">
            <el-button type="primary" :disabled="isUploading">{{btnText}}</el-button>
          </el-upload>
          <div class="search-con">
            <el-input v-model="search" clearable placeholder="标签名称" @input="cancelSearch('label', 'search')" />
            <el-button type="primary" @click="handleSearch('label', 'search')"><i class="el-icon-search"></i> 搜索</el-button>
          </div>
        </div>
        <a
          class="link-a"
          href="./excel_template/label_template.xlsx"
          target="_blank"
        >
          下载Excel上传模板
          <i class="el-icon-download"></i>
        </a>
        <el-table v-loading="loading" stripe :data="labels" :default-sort = "{prop: 'createDate', order: 'descending'}">
          <el-table-column :label="'标签'" prop="nameZ">
          </el-table-column>
          <el-table-column label="创建时间" sortable prop="createDate">
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                v-if="!(scope.row.labelQuestionId === 1 || scope.row.labelQuestionId === 2 || scope.row.labelQuestionId === 3 || scope.row.labelQuestionId === 4)"
                @click="updateLabel(scope.row)"
                type="default"
                circle
                icon="el-icon-edit"
              ></el-button>
              <el-button
                @click="deleteData('标签', 'label', scope.row)"
                type="danger"
                circle
                icon="el-icon-delete"
                v-if="!(scope.row.labelQuestionId === 1 || scope.row.labelQuestionId === 2 || scope.row.labelQuestionId === 3 || scope.row.labelQuestionId === 4)"
              ></el-button>
              <span v-if="scope.row.labelQuestionId === 1 || scope.row.labelQuestionId === 2 || scope.row.labelQuestionId === 3 || scope.row.labelQuestionId === 4">禁止操作</span>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'label')"
          :total="labelTotal">
        </el-pagination>
      </el-tab-pane>
      <el-tab-pane label="不定类型题目维护">
        <el-button type="primary" @click="openNoTypeDialog">
          <i class="el-icon-plus"></i>
          添加不定类型题目
        </el-button>
        <el-table :data="noTypeList" stripe border class="m-t-b" v-loading="typeLoading">
          <el-table-column label="题目名称" prop="nameZ"></el-table-column>
          <el-table-column label="创建时间" prop="createDate"></el-table-column>
          <el-table-column label="选择哪个选项出现填空">
            <template slot-scope="scope">
              {{scope.row.badAnswer ? scope.row.badAnswer : '暂无'}}
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="default" icon="el-icon-edit" circle @click="openNoTypeEditDialog(scope.row)"></el-button>
              <el-button type="danger" icon="el-icon-delete" circle @click="deleteData('不定类型', 'noType', scope.row)"></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'noType')"
          :total="noTypeTotal">
        </el-pagination>
      </el-tab-pane>
      <el-tab-pane label="图片上传类题目">
        <el-button type="primary" @click="openImgDialog">
          <i class="el-icon-plus"></i>
          添加题目
        </el-button>
        <el-table :data="imgList" stripe border class="m-t-b" v-loading="imgLoading">
          <el-table-column label="题目名称" prop="nameZ"></el-table-column>
          <el-table-column label="创建时间" prop="createDate"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="default" circle icon="el-icon-edit" @click="openImgEdit(scope.row)"></el-button>
              <el-button type="danger" circle icon="el-icon-delete" @click="deleteData('题目', 'img', scope.row)"></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'img')"
          :total="imgTotal">
        </el-pagination>
      </el-tab-pane>
      <el-tab-pane label="问题维护">
        <div class="header-con">
          <el-button @click="openQuestionDialog" type="primary"><i class="el-icon-plus"></i> 添加问题</el-button>
          <!-- <el-button type="primary" disabled @click="uploadFile('question')">批量导入</el-button> -->
          <div class="search-con">
            <el-input v-model="searchQuestion" clearable placeholder="问题描述" @input="cancelSearch('question', 'searchQuestion')" />
            <el-button type="primary" @click="handleSearch('question', 'searchQuestion')"><i class="el-icon-search"></i> 搜索</el-button>
          </div>
        </div>
        <el-table stripe :data="questions" v-loading="loading">
          <el-table-column label="缺乏症" width="100" type="expand">
            <template slot-scope="scope">
              <span
                style="display: block;"
                v-for="(item, i) in scope.row.labelQuestionAgeusiaList"
                :key="i"
              >{{item.ageusiaZ}}</span>
            </template>
          </el-table-column>
          <el-table-column label="问题(中文)" width="200" prop="nameZ"></el-table-column>
          <el-table-column label="问题(维吾尔语)" width="200" prop="nameW"></el-table-column>
          <el-table-column label="问题(柯尔克孜语)" width="200" prop="nameK"></el-table-column>
          <el-table-column label="A" prop="a">
          </el-table-column>
          <el-table-column label="A权重">
            <template slot-scope="scope">
              {{scope.row.labelQuestionAgeusiaList[0] && scope.row.labelQuestionAgeusiaList[0].weightA}}
            </template>
          </el-table-column>
          <el-table-column label="B" prop="b">
          </el-table-column>
          <el-table-column label="B权重">
            <template slot-scope="scope">
              {{scope.row.labelQuestionAgeusiaList[0] && scope.row.labelQuestionAgeusiaList[0].weightB}}
            </template>
          </el-table-column>
          <el-table-column label="C" prop="c">
          </el-table-column>
          <el-table-column label="C权重">
            <template slot-scope="scope">
              {{scope.row.labelQuestionAgeusiaList[0] && scope.row.labelQuestionAgeusiaList[0].weightC}}
            </template>
          </el-table-column>
          <el-table-column label="D" prop="d">
          </el-table-column>
          <el-table-column label="D权重">
            <template slot-scope="scope">
              {{scope.row.labelQuestionAgeusiaList[0] && scope.row.labelQuestionAgeusiaList[0].weightD}}
            </template>
          </el-table-column>
          <el-table-column label="创建时间" prop="createDate"></el-table-column>
          <el-table-column fixed="right" width="200" label="操作">
            <template slot-scope="scope">
              <el-button type="default" @click="updateQuestion(scope.row)" icon="el-icon-edit" circle></el-button>
              <el-button type="danger" @click="deleteData('问题', 'question', scope.row)" icon="el-icon-delete" circle></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'question')"
          :total="questionTotal">
        </el-pagination>
      </el-tab-pane>
      <el-tab-pane label="症状维护">
        <div class="header-con">
          <el-button @click="openSymptomDialog" style="margin-right: 10px;" type="primary"><i class="el-icon-plus"></i> 添加症状</el-button>
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :disabled="isUploading"
            :http-request="uploadSymptomExcel"
            :before-upload="beforeAvatarUpload">
            <el-button type="primary" :disabled="isUploading">{{btnText}}</el-button>
          </el-upload>
          <div class="search-con">
            <el-input v-model="searchSymptom" clearable placeholder="症状" @input="cancelSearch('symptom', 'searchSymptom')" />
            <el-button type="primary" @click="handleSearch('symptom', 'searchSymptom')"><i class="el-icon-search"></i> 搜索</el-button>
          </div>
        </div>
        <a
          class="link-a"
          href="./excel_template/symptom_template.xlsx"
          target="_blank"
        >
          下载Excel上传模板
          <i class="el-icon-download"></i>
        </a>
        <el-table stripe :data="symptoms" v-loading="loading1">
          <el-table-column label="症状(中文)" prop="symptomZ"></el-table-column>
          <el-table-column label="症状(维吾尔语)" prop="symptomW"></el-table-column>
          <el-table-column label="症状(柯尔克孜语)" prop="symptomK"></el-table-column>
          <el-table-column label="创建时间" prop="createDate"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="default" @click="updateSymptom(scope.row)" icon="el-icon-edit" circle></el-button>
              <el-button type="danger" @click="deleteData('症状', 'symptom', scope.row)" icon="el-icon-delete" circle></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'symptom')"
          :total="symptomTotal">
        </el-pagination>
      </el-tab-pane>
      <el-tab-pane label="描述维护">
        <div class="header-con">
          <el-button @click="openDescriptionDialog" style="margin-right: 10px;" type="primary"><i class="el-icon-plus"></i> 添加描述</el-button>
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :disabled="isUploading"
            :http-request="uploadDescExcel"
            :before-upload="beforeAvatarUpload">
            <el-button type="primary" :disabled="isUploading">{{btnText}}</el-button>
          </el-upload>
          <div class="search-con">
            <el-input v-model="searchDescription" clearable placeholder="描述" @input="cancelSearch('description', 'searchDescription')" />
            <el-button type="primary" @click="handleSearch('description', 'searchDescription')"><i class="el-icon-search"></i> 搜索</el-button>
          </div>
        </div>
        <a
          class="link-a"
          href="./excel_template/description_template.xlsx"
          target="_blank"
        >
          下载Excel上传模板
          <i class="el-icon-download"></i>
        </a>
        <el-table stripe :data="descriptions" v-loading="loading2">
          <el-table-column label="描述(中文)" prop="descriptionZ"></el-table-column>
          <el-table-column label="描述(维吾尔语)" prop="descriptionW"></el-table-column>
          <el-table-column label="描述(柯尔克孜语)" prop="descriptionK"></el-table-column>
          <el-table-column label="创建时间" prop="createDate"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="default" @click="updateDescription(scope.row)" icon="el-icon-edit" circle></el-button>
              <el-button type="danger" @click="deleteData('描述', 'description', scope.row)" icon="el-icon-delete" circle></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'description')"
          :total="descriptionTotal">
        </el-pagination>
      </el-tab-pane>
      <el-tab-pane label="缺乏症维护">
        <div class="header-con">
          <el-button @click="openLackDialog" style="margin-right: 10px;" type="primary"><i class="el-icon-plus"></i> 添加缺乏症</el-button>
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :disabled="isUploading"
            :http-request="uploadLackExcel"
            :before-upload="beforeAvatarUpload">
            <el-button type="primary" :disabled="isUploading">{{btnText}}</el-button>
          </el-upload>
          <div class="search-con">
            <el-input v-model="searchLack" clearable placeholder="缺乏症"  @input="cancelSearch('lack', 'searchLack')" />
            <el-button type="primary" @click="handleSearch('lack', 'searchLack')"><i class="el-icon-search"></i> 搜索</el-button>
          </div>
        </div>
        <a
          class="link-a"
          href="./excel_template/ageusia_template.xlsx"
          target="_blank"
        >
          下载Excel上传模板
          <i class="el-icon-download"></i>
        </a>
        <el-table stripe :data="lacks" v-loading="loading3">
          <el-table-column label="缺乏症(中文)" prop="ageusiaZ"></el-table-column>
          <el-table-column label="缺乏症(维吾尔语)" prop="ageusiaW"></el-table-column>
          <el-table-column label="缺乏症(柯尔克孜语)" prop="ageusiaK"></el-table-column>
          <el-table-column label="语言种类">
            <template slot-scope="scope">
              {{scope.row.languageType | languageTypeFilter}}
            </template>
          </el-table-column>
          <el-table-column label="创建时间" prop="createDate"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="default" @click="updateLack(scope.row)" icon="el-icon-edit" circle></el-button>
              <el-button type="danger" @click="deleteData('缺乏症', 'lack', scope.row)" icon="el-icon-delete" circle></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'lack')"
          :total="lackTotal">
        </el-pagination>
      </el-tab-pane>
      <el-tab-pane label="结果维护">
        <div class="header-con">
          <el-button @click="openResultDialog" style="margin-right: 10px;" type="primary"><i class="el-icon-plus"></i> 添加结果</el-button>
          <el-upload
            action="https://jsonplaceholder.typicode.com/posts/"
            :show-file-list="false"
            :disabled="isUploading"
            :http-request="uploadResultExcel"
            :before-upload="beforeAvatarUpload">
            <el-button type="primary" :disabled="isUploading">{{btnText}}</el-button>
          </el-upload>
          <div class="search-con">
            <el-input v-model="searchResult" clearable placeholder="结果" @input="cancelSearch('result', 'searchResult')" />
            <el-button type="primary" @click="handleSearch('result', 'searchResult')"><i class="el-icon-search"></i> 搜索</el-button>
          </div>
        </div>
        <a
          class="link-a"
          href="./excel_template/result_template.xlsx"
          target="_blank"
        >
          下载Excel上传模板
          <i class="el-icon-download"></i>
        </a>
        <el-table stripe :data="results" v-loading="loading4">
          <el-table-column label="结果" prop="result"></el-table-column>
          <el-table-column label="创建时间" prop="createDate"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button type="default" @click="updateResult(scope.row)" icon="el-icon-edit" circle></el-button>
              <el-button type="danger" @click="deleteData('结果', 'result', scope.row)" icon="el-icon-delete" circle></el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          class="m-t-b flex"
          :page-size="pageSize"
          layout="prev, pager, next"
          @current-change="handlePageChange($event, 'result')"
          :total="resultTotal">
        </el-pagination>
      </el-tab-pane>
    </el-tabs>
    <el-dialog class="label-dialog" :title="labelDialogTitle" :visible.sync="showLabelDialog">
      <el-form :model="label" :rules="rules" ref="blank">
        <el-form-item label="标签" prop="nameZ">
          <el-input v-model="label.nameZ" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hideLabelDialog">取 消</el-button>
        <el-button type="primary" @click="addLabel('blank')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 问题维护 -->
    <el-dialog :title="questionDialogTitle" :visible.sync="showQuestionDialog">
      <el-form :model="question" ref="question" :rules="rules">
        <el-form-item label="问题(中文)" prop="nameZ">
          <el-input v-model="question.nameZ" />
        </el-form-item>
        <el-form-item label="问题(维吾尔语)" prop="nameW">
          <el-input v-model="question.nameW" />
        </el-form-item>
        <el-form-item label="问题(柯尔克孜语)" prop="nameK">
          <el-input v-model="question.nameK" />
        </el-form-item>
        <el-form-item label="缺乏症" prop="labelQuestionAgeusiaList">
          <el-select filterable multiple v-model="question.labelQuestionAgeusiaList">
            <el-option v-for="item in allLacks" :key="item.ageusiaId" :value="item.ageusiaId" :label="item.ageusiaZ"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="选项A" prop="a">
          <el-input v-model="question.a" />
        </el-form-item>
        <el-form-item label="A权重">
          <el-input-number v-model="question.weightA" :min="0" :max="100"></el-input-number>
        </el-form-item>
        <el-form-item label="选项B" prop="b">
          <el-input v-model="question.b" />
        </el-form-item>
        <el-form-item label="B权重">
          <el-input-number v-model="question.weightB" :min="0" :max="100"></el-input-number>
        </el-form-item>
        <el-form-item label="选项C" prop="c">
          <el-input v-model="question.c" />
        </el-form-item>
        <el-form-item label="C权重">
          <el-input-number v-model="question.weightC" :min="0" :max="100"></el-input-number>
        </el-form-item>
        <el-form-item label="选项D" prop="d">
          <el-input v-model="question.d" />
        </el-form-item>
        <el-form-item label="D权重">
          <el-input-number v-model="question.weightD" :min="0" :max="100"></el-input-number>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showQuestionDialog = false">取 消</el-button>
        <el-button type="primary" @click="addQuestion('question')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 症状维护 -->
    <el-dialog :title="symptomDialogTitle" :visible.sync="showSymptomDialog">
      <el-form :model="symptom" ref="symptom" :rules="rules">
        <el-form-item prop="symptomZ" label="症状(中文)">
          <el-input v-model="symptom.symptomZ" />
        </el-form-item>
        <el-form-item prop="symptomW" label="症状(维吾尔语)">
          <el-input v-model="symptom.symptomW" />
        </el-form-item>
        <el-form-item prop="symptomK" label="症状(柯尔克孜语)">
          <el-input v-model="symptom.symptomK" />
        </el-form-item>
        <!-- <el-form-item label="语言类型">
          <el-select v-model="languageType">
            <el-option label="汉语" :value="0"></el-option>
            <el-option label="新疆柯汉语" :value="1"></el-option>
            <el-option label="新疆维汉语" :value="2"></el-option>
          </el-select>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hideSymptomDialog">取 消</el-button>
        <el-button type="primary" @click="addSymptom('symptom')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 描述维护 -->
    <el-dialog :title="descriptionDialogTitle" :visible.sync="showDescriptionDialog">
      <el-form :model="description" ref="description" :rules="rules">
        <el-form-item label="描述(中文)" prop="descriptionZ">
          <el-input
            type="textarea"
            rows="4"
            maxlength="200"
            show-word-limit
            v-model="description.descriptionZ"
          />
        </el-form-item>
        <el-form-item label="描述(维吾尔语)" prop="descriptionW">
          <el-input
            type="textarea"
            rows="4"
            maxlength="200"
            show-word-limit
            v-model="description.descriptionW"
          />
        </el-form-item>
        <el-form-item label="描述(柯尔克孜语)" prop="descriptionK">
          <el-input
            type="textarea"
            rows="4"
            maxlength="200"
            show-word-limit
            v-model="description.descriptionK"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hideDescriptionDialog">取 消</el-button>
        <el-button type="primary" @click="addDescription('description')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 缺乏症维护 -->
    <el-dialog :title="lackDialogTitle" :visible.sync="showLackDialog">
      <el-form :model="lack" ref="lack" :rules="rules">
        <el-form-item label="缺乏症名称(中文)" prop="ageusiaZ">
          <el-input v-model="lack.ageusiaZ" />
        </el-form-item>
        <el-form-item label="缺乏症名称(维吾尔语)" prop="ageusiaW">
          <el-input v-model="lack.ageusiaW" />
        </el-form-item>
        <el-form-item label="缺乏症名称(柯尔克孜语)" prop="ageusiaK">
          <el-input v-model="lack.ageusiaK" />
        </el-form-item>
        <!-- <el-form-item label="语言类型">
          <el-select v-model="languageType">
            <el-option label="汉语" :value="0"></el-option>
            <el-option label="新疆柯汉语" :value="1"></el-option>
            <el-option label="新疆维汉语" :value="2"></el-option>
          </el-select>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hideLackDialog">取 消</el-button>
        <el-button type="primary" @click="addLack('lack')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 结果维护 -->
    <el-dialog :title="resultDialogTitle" :visible.sync="showResultDialog">
      <el-form :model="result" ref="result" :rules="rules">
        <el-form-item label="结果" prop="result">
          <el-input v-model="result.result" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hideResultDialog">取 消</el-button>
        <el-button type="primary" @click="addResult('result')">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 不定类型题目弹窗 -->
    <el-dialog :title="noTypeDialogTitle" :visible.sync="showNoTypeDialog">
      <el-form :model="noType" :rules="rules" ref="noType" label-position="top">
        <el-form-item label="问题名称" prop="nameZ">
          <el-input v-model="noType.nameZ" />
        </el-form-item>
        <el-form-item label="选择哪个选项出现填空" prop="badAnswer">
          <el-select v-model="noType.badAnswer">
            <el-option value="是" label="是"></el-option>
            <el-option value="否" label="否"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hideNoTypeDialog">取 消</el-button>
        <el-button type="primary" @click="addNoType('noType')">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="imgDialogTitle" :visible.sync="showImgDialog">
      <el-form :model="img" ref="img" :rules="rules" label-position="top">
        <el-form-item label="题目名称" prop="nameZ">
          <el-input v-model="img.nameZ" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="hideImgDialog">取 消</el-button>
        <el-button type="primary" @click="addImg('img')">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { cloneObject, formatDate, notifySuccess } from '../util'
import {
  getLabelQuestionList,
  addLabelQuestion,
  deleteLabelQuestion,
  updateLabelQuestion,
  addSymptom,
  updateSymptom,
  deleteSymptom,
  getSymptomList,
  getDescription,
  addDescription,
  updateDescription,
  deleteDescription,
  getLackList,
  getAllLackList,
  addLack,
  deleteLack,
  updateLack,
  getResultList,
  deleteResult,
  updateResult,
  uploadExcel,
  addResult
} from '../api'

export default {
  name: 'health_data',
  data () {
    const question = {
      type: 2,
      nameZ: '',
      nameW: '',
      nameK: '',
      a: '',
      b: '',
      c: '',
      d: '',
      weightA: 0,
      weightB: 0,
      weightC: 0,
      weightD: 0,
      labelQuestionAgeusiaList: ''
    }
    const originalQuestion = cloneObject(question)
    return {
      typeLoading: false,
      imgLoading: false,
      noTypeDialogTitle: '添加不定类型问题',
      showNoTypeDialog: false,
      isUploading: false,
      btnText: '批量导入',
      curLabelPage: 1,
      labelTotal: 0,
      curQuestionPage: 1,
      questionTotal: 0,
      curSymptomPage: 1,
      symptomTotal: 0,
      curDescriptionPage: 1,
      descriptionTotal: 0,
      curLackPage: 1,
      lackTotal: 0,
      curResultPage: 1,
      resultTotal: 0,
      loading: true,
      loading1: true,
      loading2: true,
      loading3: true,
      loading4: true,
      loading5: true,
      search: '',
      noTypeTotal: 0,
      noTypeList: [],
      searchQuestion: '',
      searchSymptom: '',
      searchDescription: '',
      searchLack: '',
      searchResult: '',
      labelDialogTitle: '添加标签',
      questionDialogTitle: '添加问题',
      symptomDialogTitle: '添加症状',
      descriptionDialogTitle: '添加描述',
      lackDialogTitle: '添加缺乏症',
      resultDialogTitle: '添加结果',
      showLabelDialog: false,
      showQuestionDialog: false,
      showSymptomDialog: false,
      showDescriptionDialog: false,
      showLackDialog: false,
      showResultDialog: false,
      languageType: 0, // 0:汉语 1:新疆柯汉语言 2:新疆维汉语言
      letters: ['A', 'B', 'C', 'D'],
      pageSize: 10,
      noType: {
        nameZ: '',
        badAnswer: ''
      },
      img: {
        nameZ: ''
      },
      imgList: [],
      imgTotal: 0,
      imgDialogTitle: '添加上传图片类题目',
      showImgDialog: false,
      label: {
        nameZ: ''
      },
      allLacks: [],
      labels: [],
      questions: [],
      question,
      originalQuestion,
      symptoms: [],
      rules: {
        name: [
          { required: true, message: '名称不能为空', trigger: 'blur' }
        ],
        a: [
          { required: true, message: '选项不能为空', trigger: 'blur' }
        ],
        b: [
          { required: true, message: '选项不能为空', trigger: 'blur' }
        ],
        labelQuestionAgeusiaList: [
          { required: true, message: '缺乏症不能为空', trigger: 'change' }
        ],
        c: [
          { required: true, message: '选项不能为空', trigger: 'blur' }
        ],
        d: [
          { required: true, message: '选项不能为空', trigger: 'blur' }
        ],
        symptom: [
          { required: true, message: '名称不能为空', trigger: 'blur' },
          { min: 2, max: 20, message: '字段为 2 到 10 个字符', trigger: 'blur' }
        ],
        description: [
          { required: true, message: '该项不能为空', trigger: 'blur' }
        ],
        ageusia: [
          { required: true, message: '该项不能为空', trigger: 'blur' }
        ],
        result: [
          { required: true, message: '该项不能为空', trigger: 'blur' }
        ],
        badAnswer: [
          { required: true, message: '该项不能为空', trigger: 'change' }
        ]
      },
      symptom: {
        symptomZ: '',
        symptomW: '',
        symptomK: ''
      },
      descriptions: [],
      description: {
        descriptionZ: '',
        descriptionW: '',
        descriptionK: ''
      },
      lacks: [],
      lack: {
        ageusiaZ: '',
        ageusiaW: '',
        ageusiaK: ''
      },
      results: [],
      result: {
        result: ''
      }
    }
  },
  methods: {
    openNoTypeDialog () { // 打开不定类型弹出框
      this.noType.nameZ = '';
      this.noType.badAnswer = '';
      this.noTypeDialogTitle = '添加不定类型问题';
      this.showNoTypeDialog = true
    },
    hideImgDialog () { // 隐藏上传图片弹出框
      this.showImgDialog = false
    },
    openImgEdit (data) { // 打开上传图片弹出框
      this.img.nameZ = data.nameZ;
      this.img.id = data.labelQuestionId;
      this.imgDialogTitle = '修改上传图片类题目';
      this.showImgDialog = true
    },
    addImg (name) {
      this.$refs[name].validate(valid => {
        if (valid) {
          if (this.imgDialogTitle === '添加上传图片类题目') {
            addLabelQuestion({
              type: 4,
              nameZ: this.img.nameZ
            })
            .then(res => {
              if (res.data.code === 1) {
                this.$message({
                  type: 'success',
                  message: '添加成功'
                });
                this.showImgDialog = false;
                this.fetchLabelQuestionList(1, 4)
              } else {
                this.$message.error(res.data.msg || '服务异常!')
              }
            })
            .catch(e => {
              this.$message.error('服务异常!')
            })
          } else {
            this.handleUpdateLabel(4, {
              labelQuestionId: this.img.id,
              nameZ: this.img.nameZ,
              type: 4
            })
          }
        } else {
          return false
        }
      })
    },
    openImgDialog () { // 打开上传图片类题目弹出框
      this.imgDialogTitle = '添加上传图片类题目';
      this.img.nameZ = '';
      this.showImgDialog = true
    },
    tabClick ({ index }) {
      if (index === '1') {
        if (!this.noTypeList.length) {
          this.fetchLabelQuestionList(1, 3)
        }
      } else if (index === '2') {
        if (!this.imgList.length) {
          this.fetchLabelQuestionList(1, 4)
        }
      }
    },
    hideNoTypeDialog () { // 隐藏不定类型问题弹出框
      this.showNoTypeDialog = false
    },
    openNoTypeEditDialog (data) { // 打开修改不定项弹出框
      this.noType.nameZ = data.nameZ;
      this.noType.badAnswer = data.badAnswer || '';
      this.noType.id = data.labelQuestionId;
      this.noTypeDialogTitle = '修改不定类型问题';
      this.showNoTypeDialog = true
    },
    addNoType (name) { // 添加不定类型问题
      this.$refs[name].validate(valid => {
        if (valid) {
          if (this.noTypeDialogTitle === '添加不定类型问题') {
            addLabelQuestion({
              type: 3,
              ...this.noType
            })
            .then(res => {
              if (res.data.code === 1) {
                this.$message({
                  type: 'success',
                  message: '添加成功!'
                });
                this.showNoTypeDialog = false;
                this.fetchLabelQuestionList(1, 3)
              } else {
                this.$message.error('服务异常!')
              }
            })
            .catch(e => {
              this.$message.error('服务异常!')
            })
          } else {
            this.handleUpdateLabel(3, {
              labelQuestionId: this.noType.id,
              nameZ: this.noType.nameZ,
              badAnswer: this.noType.badAnswer,
              type: 3
            })
          }
        } else {
          return false
        }
      })
    },
    beforeAvatarUpload(file) {
      let name = file.name
      let type = name.split('.').pop()
      const isXLSX = type === 'xlsx'
      const isXLS = type === 'xls'
      if (!isXLSX && !isXLS) {
        this.$message.error('只能上传Excel文件, 后缀为.xls或.xlsx')
      }
      return isXLS || isXLSX
    },
    uploadExcel ({ file }) { // 上传标签
      this.handleUploadExcel(file, 6)
    },
    uploadSymptomExcel ({ file }) { // 上传症状
      this.handleUploadExcel(file, 4)
    },
    uploadDescExcel ({ file }) { // 上传描述
      this.handleUploadExcel(file, 2)
    },
    uploadLackExcel ({ file }) { // 上传缺乏症
      this.handleUploadExcel(file, 1)
    },
    uploadResultExcel ({ file }) { // 上传结果
      this.handleUploadExcel(file, 3)
    },
    handleUploadExcel (file, type) {
      this.isUploading = true
      this.btnText = '上传中...'
      const formData = new FormData()
      formData.append('type', type)
      formData.append('file', file)
      uploadExcel(formData)
      .then(res => {
        if (res.data.code === 1) {
          notifySuccess(this)
          switch (type) {
            case 6:
              this.fetchLabelQuestionList(1, 1)
              break
            case 4:
              this.fetchSymptomList(1)
              break
            case 2:
              this.fetchDescriptionList(1)
              break
            case 1:
              this.fetchLackList(1)
              break
            case 3:
              this.fetchResultList(1)
              break
            default:
              break
          }
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
        this.isUploading = false
        this.btnText = '批量上传'
      })
      .catch(e => {
        this.$message.error('网络异常!')
        this.isUploading = false
        this.btnText = '批量上传'
      })
    },
    updateLabel (label) { // 标签修改
      this.labelDialogTitle = '修改标签'
      this.label = label
      this.showLabelDialog = true
    },
    transDate (time) {
      return formatDate(time)
    },
    deleteData (label, type, obj) { // 标签删除
      this.$confirm(`此操作将永久删除该${label}, 是否继续?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (type === 'label') {
          deleteLabelQuestion(obj.labelQuestionId)
          .then(res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchLabelQuestionList(1, 1)
            }
          })
        } else if (type === 'symptom') {
          deleteSymptom(obj.symptomId)
          .then(res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchSymptomList(1)
            } else {
              this.$message.error(res.data.msg || '网络异常!')
            }
          })
          .catch(e => {
            this.$message.error('网络异常!')
          })
        } else if (type === 'description') {
          deleteDescription(obj.descriptionId)
          .then (res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchDescriptionList(1)
            } else {
              this.$message.error(res.data.msg || '网络异常!')
            }
          })
          .catch(e => {
            this.$message.error('网络异常!')
          })
        } else if (type === 'lack') {
          deleteLack(obj.ageusiaId)
          .then(res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchLackList(1)
            } else {
              this.$message.error(res.data.msg || '网络异常!')
            }
          })
          .catch(e => {
            this.$message.error('网络异常!')
          })
        } else if (type === 'result') {
          deleteResult(obj.resultId)
          .then(res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchResultList(1)
            } else {
              this.$message.error('网络异常!')
            }
          })
          .catch(e => {
            this.$message.error('网络异常!')
          })
        } else if (type === 'question') {
          deleteLabelQuestion(obj.labelQuestionId)
          .then(res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchLabelQuestionList(1, 2)
            } else {
              this.$message.error(res.data.msg || '网络异常!')
            }
          })
          .catch(e => {
            this.$message.error('网络异常!')
          })
        } else if (type === 'noType') {
          deleteLabelQuestion(obj.labelQuestionId)
          .then(res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchLabelQuestionList(1, 3)
            } else {
              this.$message.error(res.data.msg || '网络异常!')
            }
          })
          .catch(e => {
            this.$message.error('网络异常!')
          })
        } else if (type === 'img') {
          deleteLabelQuestion(obj.labelQuestionId)
          .then(res => {
            if (res.data.code === 1) {
              notifySuccess(this)
              this.fetchLabelQuestionList(1, 4)
            } else {
              this.$message.error(res.data.msg || '网络异常!')
            }
          })
          .catch(e => {
            this.$message.error('网络异常!')
          })
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        })
      })
    },
    openLabelDialog () { // 打开添加标签对话框
      this.label.nameZ = ''
      this.labelDialogTitle = '添加标签'
      this.showLabelDialog = true
    },
    openQuestionDialog () {
      this.questionDialogTitle = '添加问题'
      this.question = this.originalQuestion
      this.languageType = 0
      this.showQuestionDialog = true
    },
    hideLabelDialog () { // 隐藏标签对话框
      this.showLabelDialog = false
    },
    addLabel (form) { // 添加标签
      this.$refs[form].validate(valid => {
        if (valid) {
          if (this.labelDialogTitle === '修改标签') {
            this.handleUpdateLabel(1, {
              labelQuestionId: this.label.labelQuestionId,
              type: 1,
              nameZ: this.label.nameZ,
            })
          } else {
            this.handleAddLabel(1, {
              nameZ: this.label.nameZ,
              type: 1
            })
          }
        } else {
          return false
        }
      })
    },
    handleAddLabel (type, data) { // 添加标签问题
      addLabelQuestion(data)
      .then(res => {
        if (res.data.code === 1) {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
          if (type === 1) {
            this.showLabelDialog = false
            this.fetchLabelQuestionList(1, 1)
          } else {

          }
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
      })
      .catch(e => {
        this.$message.error('网络异常!')
      })
    },
    handleUpdateLabel (type, data) { // 更新标签问题
      updateLabelQuestion(data)
      .then(res => {
        if (res.data.code === 1) {
          notifySuccess(this)
          if (type === 1) {
            this.showLabelDialog = false
            this.fetchLabelQuestionList(1, 1)
          } else if (type === 2) {
            this.showQuestionDialog = false
            this.fetchLabelQuestionList(1, 2)
          } else if (type === 3) {
            this.showNoTypeDialog = false;
            this.fetchLabelQuestionList(1, 3)
          } else if (type === 4) {
            this.showImgDialog = false;
            this.fetchLabelQuestionList(1, 4)
          }
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
      })
      .catch(e => {
        this.$message.error('网络异常!')
      })
    },
    handleSearch (type, model) {
      if (!this[model].trim()) {
        this[model] = ''
        return this.$message.error('请输入搜索内容!')
      }
      switch (type) {
        case 'label':
          this.fetchLabelQuestionList(1, 1, this[model])
          break
        case 'symptom':
          this.fetchSymptomList(1, this[model])
          break
        case 'description':
          this.fetchDescriptionList(1, this[model])
          break
        case 'lack':
          this.fetchLackList(1, this[model])
          break
        case 'result':
          this.fetchResultList(1, this[model])
          break
        case 'question':
          this.fetchLabelQuestionList(1, 2, this[model])
          break
        default:
          break
      }
    },
    updateQuestion (question) {
      console.log(question)
      let labelList = question.labelQuestionAgeusiaList[0] || {};
      this.question = {
        labelQuestionId: question.labelQuestionId,
        type: 2,
        nameZ: question.nameZ,
        nameW: question.nameW,
        nameK: question.nameK,
        weightA: labelList.weightA,
        weightB: labelList.weightB,
        weightC: labelList.weightC,
        weightD: labelList.weightD,
        a: question.a,
        b: question.b,
        c: question.c,
        d: question.d,
        labelQuestionAgeusiaList: question.labelQuestionAgeusiaList.map(item => {
          return item.ageusiaId
        })
      }
      this.questionDialogTitle = '修改问题'
      this.showQuestionDialog = true
    },
    addQuestion (form) {
      this.$refs[form].validate(valid => {
        if (valid) {
          let question = {
            type: 2,
            languageType: this.languageType,
            nameZ: this.question.nameZ,
            nameW: this.question.nameW,
            nameK: this.question.nameK,
            a: this.question.a,
            b: this.question.b,
            c: this.question.c,
            d: this.question.d,
            labelQuestionAgeusiaList: this.question.labelQuestionAgeusiaList.map(item => {
              return {
                ageusiaId: item,
                weightA: this.question.weightA,
                weightB: this.question.weightB,
                weightC: this.question.weightC,
                weightD: this.question.weightD
              }
            })
          }
          if (this.questionDialogTitle === '修改问题') {
            question.labelQuestionId = this.question.labelQuestionId
            this.handleUpdateLabel(2, question)
          } else {
            addLabelQuestion(question)
            .then(res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showQuestionDialog = false
                this.fetchLabelQuestionList(1, 2)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch(e => {
              this.$message.error('网络异常!')
            })
          }
        } else {
          return false
        }
      })
    },
    openSymptomDialog () {
      this.symptom.symptomZ = ''
      this.symptom.symptomW = ''
      this.symptom.symptomK = ''
      this.symptomDialogTitle = '添加症状'
      this.languageType = 0
      this.showSymptomDialog = true
    },
    updateSymptom (symptom) {
      this.symptom = symptom
      this.symptomDialogTitle = '修改症状'
      this.showSymptomDialog = true
    },
    hideSymptomDialog () {
      this.showSymptomDialog = false
    },
    addSymptom (form) {
      this.$refs[form].validate(valid => {
        if (valid) {
          if (this.symptomDialogTitle === '修改症状') {
            updateSymptom({
              symptomId: this.symptom.symptomId,
              symptomZ: this.symptom.symptomZ,
              symptomW: this.symptom.symptomW,
              symptomK: this.symptom.symptomK
            })
            .then(res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showSymptomDialog = false
                this.fetchSymptomList(1)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch(e => {
              this.$message.error('网络异常!')
            })
          } else {
            addSymptom({
              symptomZ: this.symptom.symptomZ,
              symptomW: this.symptom.symptomW,
              symptomK: this.symptom.symptomK
            })
            .then(res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showSymptomDialog = false
                this.fetchSymptomList(1)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch(e => {
              this.$message.error('网络异常!')
            })
          }
        } else {
          return false
        }
      })
    },
    openDescriptionDialog () {
      this.description.descriptionZ = ''
      this.description.descriptionW = ''
      this.description.descriptionK = ''
      this.descriptionDialogTitle = '添加描述'
      this.languageType = 0
      this.showDescriptionDialog = true
    },
    updateDescription (desc) {
      this.description = desc
      this.descriptionDialogTitle = '修改描述'
      this.showDescriptionDialog = true
    },
    hideDescriptionDialog () {
      this.showDescriptionDialog = false
    },
    addDescription (form) {
      this.$refs[form].validate(valid => {
        if (valid) {
          if (this.descriptionDialogTitle === '修改描述') {
            updateDescription({
              descriptionId: this.description.descriptionId,
              descriptionZ: this.description.descriptionZ,
              descriptionW: this.description.descriptionW,
              descriptionK: this.description.descriptionK,
            })
            .then (res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showDescriptionDialog = false
                this.fetchDescriptionList(1)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch (e => {
              this.$message.error('网络异常!')
            })
          } else {
            addDescription({
              descriptionZ: this.description.descriptionZ,
              descriptionW: this.description.descriptionW,
              descriptionK: this.description.descriptionK,
            })
            .then (res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showDescriptionDialog = false
                this.fetchDescriptionList(1)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch (e => {
              this.$message.error('网络异常!')
            })
          }
        } else {
          return false
        }
      })
    },
    openLackDialog () {
      this.lackDialogTitle = '添加缺乏症'
      this.lack.ageusiaZ = ''
      this.lack.ageusiaW = ''
      this.lack.ageusiaK = ''
      this.languageType = 0
      this.showLackDialog = true
    },
    updateLack (lack) {
      this.lackDialogTitle = '修改缺乏症'
      this.lack = lack;
      // this.lack.ageusiaZ = lack.ageusiaZ;
      // this.lack.ageusiaW = lack.ageusiaW;
      // this.lack.ageusiaK = lack.ageusiaK;
      this.showLackDialog = true
    },
    hideLackDialog () {
      this.showLackDialog = false
    },
    addLack (form) {
      this.$refs[form].validate(valid => {
        if (valid) {
          if (this.lackDialogTitle === '修改缺乏症') {
            updateLack({
              ageusiaZ: this.lack.ageusiaZ,
              ageusiaW: this.lack.ageusiaW,
              ageusiaK: this.lack.ageusiaK,
              ageusiaId: this.lack.ageusiaId,
            })
            .then(res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showLackDialog = false
                this.fetchLackList(1)
              } else {
                this.$message.error('网络异常!')
              }
            })
            .catch(e => {
              this.$message.error('网络异常!')
            })
          } else {
            addLack({
              ageusiaZ: this.lack.ageusiaZ,
              ageusiaW: this.lack.ageusiaW,
              ageusiaK: this.lack.ageusiaK,
            })
            .then(res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showLackDialog = false
                this.fetchLackList(1)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch(e => {
              this.$message.error('网络异常!')
            })
          }
        } else {
          return false
        }
      })
    },
    openResultDialog () {
      this.result.result = ''
      this.resultDialogTitle = '添加结果'
      this.showResultDialog = true
    },
    updateResult (result) {
      this.result = result
      this.resultDialogTitle = '修改结果'
      this.showResultDialog = true
    },
    hideResultDialog () {
      this.showResultDialog = false
    },
    addResult (form) {
      this.$refs[form].validate(valid => {
        if (valid) {
          if (this.resultDialogTitle === '修改结果') {
            updateResult({
              resultId: this.result.resultId,
              result: this.result.result
            })
            .then(res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showResultDialog = false
                this.fetchResultList(1)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch(e => {
              this.$message.error('网络异常!')
            })
          } else {
            addResult(this.result.result)
            .then(res => {
              if (res.data.code === 1) {
                notifySuccess(this)
                this.showResultDialog = false
                this.fetchResultList(1)
              } else {
                this.$message.error(res.data.msg || '网络异常!')
              }
            })
            .catch(e => {
              this.$message.error('网络异常!')
            })
          }
        } else {
          return false
        }
      })
    },
    handlePageChange (page, type) {
      switch (type) {
        case 'label':
          this.curLabelPage = page;
          if (this.search.trim()) {
            this.fetchLabelQuestionList(page, 1, this.search)
          } else {
            this.fetchLabelQuestionList(page, 1)
          };
          break
        case 'question':
          this.curQuestionPage = page;
          if (this.searchQuestion.trim()) {
            this.fetchLabelQuestionList(page, 2, this.searchQuestion)
          } else {
            this.fetchLabelQuestionList(page, 2)
          };
          break
        case 'symptom':
          this.curSymptomPage = page;
          if (this.searchSymptom.trim()) {
            this.fetchSymptomList(page, this.searchSymptom)
          } else {
            this.fetchSymptomList(page)
          };
          break
        case 'description':
          this.curDescriptionPage = page;
          if (this.searchDescription.trim()) {
            this.fetchDescriptionList(page, this.searchDescription)
          } else {
            this.fetchDescriptionList(page)
          }
          break
        case 'lack':
          this.curLabelPage = page;
          if (this.searchLack.trim()) {
            this.fetchLackList(page, this.searchLack)
          } else {
            this.fetchLackList(page)
          };
          break
        case 'result':
          if (this.searchResult.trim()) {
            this.fetchResultList(page, this.searchResult)
          } else {
            this.fetchResultList(page)
          }
          break
        case 'noType':
          this.fetchLabelQuestionList(page, 3)
          break
        case 'img':
          this.fetchLabelQuestionList(page, 4)
          break
        default:
          break
      }
    },
    cancelSearch (type, model) {
      if (!this[model]) {
        switch (type) {
          case 'label':
            this.fetchLabelQuestionList(1, 1)
            break
          case 'symptom':
            this.fetchSymptomList(1)
            break
          case 'description':
            this.fetchDescriptionList(1)
            break
          case 'lack':
            this.fetchLackList(1)
            break
          case 'result':
            this.fetchResultList(1)
            break
          case 'question':
            this.fetchLabelQuestionList(1, 2)
            break
          default:
            break
        }
      }
    },
    fetchLabelQuestionList (index, type, name) { // 获取标签问题
      name = name || null
      this.loading = true
      if (type === 3) {
        this.typeLoading = true
      } else if (type === 4) {
        this.imgLoading = true
      }
      getLabelQuestionList({
        index,
        count: this.pageSize,
        queryParam: {
          type: type,
          nameZ: name
        }
      })
      .then(res => {
        if (res.data.code === 1) {
          let list = res.data.data.list || []
          for (let i = 0; i < list.length; i ++) {
            list[i].createDate = formatDate(list[i].createDate)
          }
          if (type === 1) {
            this.curLabelPage = 1
            this.labelTotal = res.data.data.totalRecord
            this.labels = list
          } else if (type === 2) {
            this.questions = list;
            this.questionTotal = res.data.data.totalRecord
          } else if (type === 3) {
            this.noTypeList = list;
            this.noTypeTotal = res.data.data.totalRecord
          } else if (type === 4) {
            this.imgList = list;
            this.imgTotal = res.data.data.totalRecord
          }
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
        this.loading = false;
        if (type === 3) {
          this.typeLoading = false
        } else if (type === 4) {
          this.imgLoading = false
        }
      })
      .catch(e => {
        this.$message.error('网络异常!')
        this.loading = false
        if (type === 3) {
          this.typeLoading = false
        } else if (type === 4) {
          this.imgLoading = false
        }
      })
    },
    fetchSymptomList (index, symptom) { // 获取症状列表
      symptom = symptom || null
      this.loading1 = true
      getSymptomList({
        index,
        count: this.pageSize,
        queryParam: {
          symptomZ: symptom
        }
      })
      .then(res => {
        if (res.data.code === 1) {
          let list = res.data.data.list || []
          for (let i = 0; i< list.length; i ++) {
            list[i].createDate = formatDate(list[i].createDate)
          }
          this.symptomTotal = res.data.data.totalRecord
          this.symptoms = list
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
        this.loading1 = false
      })
      .catch(e => {
        this.$message.error('网络异常!')
        this.loading1 = false
      })
    },
    fetchDescriptionList (index, description) { // 获取描述列表
      description = description || null
      this.loading2 = true
      getDescription({
        index,
        count: this.pageSize,
        queryParam: {
          descriptionZ: description
        }
      })
      .then(res => {
        if (res.data.code === 1) {
          let list = res.data.data.list || []
          for (let i = 0; i < list.length; i ++) {
            list[i].createDate = formatDate(list[i].createDate)
          }
          this.descriptionTotal = res.data.data.totalRecord
          this.descriptions = list
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
        this.loading2 = false
      })
      .catch(e => {
        this.loading2 = false
        this.$message.error('网络异常!')
      })
    },
    fetchLackList (index, ageusiaZ) { // 获取缺乏症列表
      ageusiaZ = ageusiaZ || null
      this.loading3 = true
      getLackList({
        index,
        count: this.pageSize,
        queryParam: {
          ageusiaZ
        }
      })
      .then(res => {
        if (res.data.code === 1) {
          let list = res.data.data.list || []
          for (let i = 0; i < list.length; i ++) {
            list[i].createDate = formatDate(list[i].createDate)
          }
          this.lackTotal = res.data.data.totalRecord
          this.lacks = list
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
        this.loading3 = false
      })
      .catch(e => {
        this.loading3 = false
        this.$message.error('网络异常!')
      })
    },
    fetchAllLackList () {
      getAllLackList()
      .then(res => {
        if (res.data.code === 1) {
          let list = res.data.data || []
          for (let i = 0; i < list.length; i ++) {
            list[i].createDate = formatDate(list[i].createDate)
          };
          this.allLacks = list
        } else {
          this.$message.error(resd.data.msg || '网络异常!')
        }
      })
      .catch(e => {
        this.$message.error('网络异常!')
      })
    },
    fetchResultList (index, result) { // 获取结果列表
      result = result || null
      this.loading4 = true
      getResultList({
        index,
        count: this.pageSize,
        queryParam: {
          result
        }
      })
      .then(res => {
        if (res.data.code === 1) {
          let list = res.data.data.list || []
          for (let i = 0; i < list.length; i ++) {
            list[i].createDate = formatDate(list[i].createDate)
          }
          this.resultTotal = res.data.data.totalRecord
          this.results = list
        } else {
          this.$message.error(res.data.msg || '网络异常!')
        }
        this.loading4 = false
      })
      .catch(e => {
        this.loading4 = false
        this.$message.error('网络异常!')
      })
    },
    uploadFile (type) { // 批量导入
      console.log(type)
    }
  },
  created () {
    this.fetchLabelQuestionList(1, 1) // 获取填空题
    this.fetchLabelQuestionList(1, 2) // 获取问题
    this.fetchSymptomList(1) // 获取症状列表
    this.fetchDescriptionList(1) // 获取描述列表
    this.fetchLackList(1) // 获取缺乏症列表
    this.fetchAllLackList() // 获取所有缺乏症列表
    this.fetchResultList(1) // 获取结果列表
  },
  mounted () {
    this.$message({
      type: 'info',
      duration: 5000,
      showClose: true,
      message: '批量上传时, 请按照固定的格式上传Excel: Excel文件中应只有一列, 列名为 标签/症状/描述/缺乏症/结果, 列内容应合理, 有意义!'
    })
  },
  filters: {
    languageTypeFilter (type) {
      let res = '';
      type = Number(type);
      switch (type) {
        case 0:
          res = '汉语';
          break
        case 1:
          res = '新疆柯汉语';
          break
        case 2:
          res = '新疆维汉语';
          break
        default:
          res = '汉语';
          break
      };
      return res
    }
  }
}
</script>
<style lang="scss">
  .health-data {
    .link-a {
      cursor: pointer;
    }
    table {
      .cell {
        text-align: center;
      }
    }
    .header-con {
      display: flex;
      margin-bottom: 20px;
      align-items: center;
      .search-con {
        margin-left: 40px;
        display: flex;
        flex: 1;
      }
    }
  }
</style>
